import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
// 适配像素
import 'package:in_out_goods_manage/utiles/adapation.dart';

// 商品卡片
class GoodsCard extends HookWidget {
  const GoodsCard({
    super.key,
    this.goodsNo,
    this.goodsPrice,
    this.goodsName,
    this.goodsBrand,
    required this.onPressed,
    this.btnText,
  });
  final String? goodsNo, goodsPrice, goodsName, goodsBrand, btnText;

  final Function(String) onPressed;
  @override
  Widget build(BuildContext context) {
    return Card(
      color: const Color(0xFFFFFFFF), //卡片的颜色
      elevation: 0, //阴影的大小
      shadowColor: const Color(0xFFEAEAEA), //阴影的颜色
      margin: EdgeInsets.only(top: AdaptSize.px(20)), //外边距
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(
            AdaptSize.px(10),
          ),
        ),
      ),
      child: SizedBox(
        width: AdaptSize.px(345),
        child: Column(children: [
          Container(
            width: double.infinity,
            padding: EdgeInsets.all(AdaptSize.px(14)),
            child: Row(
              children: [
                Expanded(
                  child: Text(
                    'productNumber：${goodsNo ?? ""}',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: AdaptSize.px(14),
                    ),
                    overflow: TextOverflow.ellipsis,
                  ),
                )
              ],
            ),
          ),
          const Divider(
            height: 0,
            color: Color(0xFFE4E4E4),
          ),
          Padding(
            padding: EdgeInsets.only(
              top: AdaptSize.px(12),
              left: AdaptSize.px(14.5),
              right: AdaptSize.px(14.5),
              bottom: AdaptSize.px(20.5),
            ),
            child: Column(children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'productPrice',
                    style: TextStyle(
                      color: const Color(0xFF8A8989),
                      fontSize: AdaptSize.px(14),
                    ),
                  ),
                  Text(
                    goodsPrice ?? '',
                    style: TextStyle(
                      fontSize: AdaptSize.px(13),
                    ),
                  )
                ],
              ),
              SizedBox(height: AdaptSize.px(5)),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'productTitle',
                    style: TextStyle(
                      color: const Color(0xFF8A8989),
                      fontSize: AdaptSize.px(14),
                    ),
                  ),
                  Text(
                    goodsName ?? "",
                    style: TextStyle(
                      fontSize: AdaptSize.px(13),
                    ),
                  )
                ],
              ),
              SizedBox(height: AdaptSize.px(5)),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'productBranding',
                    style: TextStyle(
                      color: const Color(0xFF8A8989),
                      fontSize: AdaptSize.px(14),
                    ),
                  ),
                  Text(
                    goodsBrand ?? "",
                    style: TextStyle(
                      fontSize: AdaptSize.px(13),
                    ),
                  )
                ],
              ),
              SizedBox(height: AdaptSize.px(8)),
              SizedBox(
                width: double.infinity,
                height: AdaptSize.px(30),
                child: OutlinedButton(
                  style: OutlinedButton.styleFrom(
                    backgroundColor: const Color(0xFF3084FC),
                    shape: const RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    side: const BorderSide(
                      color: Color(0xFF3084FC),
                    ),
                  ),
                  onPressed: () {
                    onPressed(goodsNo!);
                  },
                  child: Text(
                    btnText ?? '',
                    style: TextStyle(
                        color: const Color(0xFFFFFFFF),
                        fontSize: AdaptSize.px(13)),
                  ),
                ),
              ),
            ]),
          ),
        ]),
      ),
    );
  }
}
